package com.lw;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * @author LW
 * @2020/9/19 13:17
 */
public class urldemo {
    public static void main(String[] args) throws MalformedURLException {
        URL url = new URL("https://p2.music.126.net/0O1DSaOFQDa0XAL1oxBDfg==/109951165325140747.jpg?param=34y34");
        System.out.println("协议："+url.getProtocol());//获取协议
        System.out.println("host:"+url.getHost());//获取主机ip
        System.out.println("路劲:"+url.getPath());//获取路径
        System.out.println("文件:"+url.getFile());
        System.out.println("port:"+url.getPort());//端口
        System.out.println("getQuery:"+url.getQuery());
    }
}
